import request from './request'

// 获取会员等级列表
export function getMemberLevelList(params) {
  return request({
    url: '/api/member-levels',
    method: 'get',
    params
  })
}

// 获取会员等级详情
export function getMemberLevelDetail(id) {
  return request({
    url: `/api/member-levels/${id}`,
    method: 'get'
  })
}

// 创建会员等级
export function createMemberLevel(data) {
  return request({
    url: '/api/member-levels',
    method: 'post',
    data
  })
}

// 更新会员等级
export function updateMemberLevel(id, data) {
  return request({
    url: `/api/member-levels/${id}`,
    method: 'put',
    data
  })
}

// 删除会员等级
export function deleteMemberLevel(id) {
  return request({
    url: `/api/member-levels/${id}`,
    method: 'delete'
  })
}

// 获取会员订单列表
export function getMemberOrderList(params) {
  return request({
    url: '/api/member-orders',
    method: 'get',
    params
  })
}

// 获取会员订单详情
export function getMemberOrderDetail(id) {
  return request({
    url: `/api/member-orders/${id}`,
    method: 'get'
  })
}

// 创建会员订单
export function createMemberOrder(data) {
  return request({
    url: '/api/member-orders',
    method: 'post',
    data
  })
}

// 更新会员订单
export function updateMemberOrder(id, data) {
  return request({
    url: `/api/member-orders/${id}`,
    method: 'put',
    data
  })
}

// 删除会员订单
export function deleteMemberOrder(id) {
  return request({
    url: `/api/member-orders/${id}`,
    method: 'delete'
  })
}

// 获取会员统计数据
export function getMemberStatistics() {
  return request({
    url: '/api/member/statistics',
    method: 'get'
  })
}

// 获取用户会员信息
export function getUserMemberInfo(userId) {
  return request({
    url: `/api/member/user/${userId}`,
    method: 'get'
  })
}

// 更新用户会员状态
export function updateUserMemberStatus(userId, status) {
  return request({
    url: `/api/member/user/${userId}/status`,
    method: 'put',
    data: { status }
  })
}

// 获取会员销售统计
export function getMemberSalesStatistics(params) {
  return request({
    url: '/api/member/sales-statistics',
    method: 'get',
    params
  })
}